package com.vol.controller.sys;
import com.vol.RedisUtils;
import com.vol.sys.LoginService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

@RestController
@RequestMapping("api/User")
public class YzmContoller {

    @Autowired
    private RedisUtils<Object> redisUtils;

    @RequestMapping("getVierificationCode")
    public Map<String, Integer> getVierificationCode() {
        //清空当前缓存数据库
        redisUtils.clear();
        int num1 = new Random().nextInt(20);
        int num2 = new Random().nextInt(10);
        int num3 = num1 + num2;
        Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("num1", num1);
        map.put("num2", num2);

        redisUtils.setKey("LoginResult",num3);
        //Object num = redisUtils.getKey("LoginResult");
        //System.out.println("num:"+num);

        return map;
    }
}
